﻿using PetaPoco;
using Shop.Wares.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shop.Wares.Repositories
{
    public class CommentsAccess
    {
        public Database DB = new Database("ConnString");

        public object AddComments(Comments comments)
        {
            return DB.Insert("Shop_Comments", "CommentId", comments);
        }
        /// <summary>
        /// 获取类别信息
        /// </summary>
        /// <returns></returns>
        public IList<Comments> GetComments(int WID)
        {
            Sql sql = Sql.Builder.Append("select * from Shop_Comments where WID = '" + WID + "' order by CommentDate desc");
            return DB.Fetch<Comments>(sql);
        }
        /// <summary>
        /// 删除类别
        /// </summary>
        /// <param name="CID">类别ID</param>
        /// <returns></returns>
        public int DelComments(int CommentId)
        {
            Sql sql = Sql.Builder.Append("delete from Shop_Comments where CommentId = @0", CommentId);
            return DB.Execute(sql);
        }
        /// <summary>
        /// 修改类别
        /// </summary>
        /// <param name="CID">l类别ID</param>
        /// <returns></returns>
        public object UpdateComments(Comments comments)
        {
            Sql sql = Sql.Builder.Append("update Shop_Comments set Comment = @0 where CommentId = @1", comments.Comment,  comments.CommentId);
            return DB.Execute(sql);
            //return DB.Update("Shop_WaresCategory", "CID", winfo);
        }
        

        
    }
}
